package cn.kgcnews.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HelloServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	String charEncoding="UTF-8";
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset="+charEncoding);
		System.out.println("这就是命！！！");
		PrintWriter out= response.getWriter();
		out.print("this is fate!!!");
		out.flush();
		out.close();
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doPost(req, resp);
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		super.destroy();
	}

	@Override
	public void init() throws ServletException {
		System.out.println("初始化的步骤1");
	}
	@Override
	public void init(ServletConfig config) throws ServletException {
		System.out.println("初始化的步骤2");
		charEncoding=config.getInitParameter("charEncoding");
		System.out.println(charEncoding);
	}
}
